package offerv1;

public class Offer24 {
    public ListNode reverseList(ListNode head) {
        ListNode index = head.next, ret = head;
        while (index != null) {
            ListNode node = index;
            index = index.next;

            node.next = ret;
            ret = node;
        }

        return ret;
    }

    public ListNode reverseList1(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode next = curr.next;
            curr.next = prev;
            prev = curr;
            curr = next;
        }
        return prev;
    }
}
